package br.com.felix.fwt.svg.shapes.path;

import java.util.Arrays;

public class SVGSimpleCommand implements SVGCommand {

	private char command;
	private int[] values;



	public SVGSimpleCommand(char command, int... values) {
		this.command = command;
		this.values = values;
	}



	public String toString() {
		StringBuilder strb = new StringBuilder(String.valueOf(command));
		for (int p : values) {
			strb.append(p).append(" ");
		}
		return strb.toString();
	}



	public void merge(SVGCommand command) {
		if (this.getSVGCommandLetter() == command.getSVGCommandLetter()) {
			if (command instanceof SVGSimpleCommand) {
				SVGSimpleCommand other = (SVGSimpleCommand) command;
				int length = this.values.length;
				values = Arrays.copyOf(values, length + other.values.length);
				for (int i = length; i < length + other.values.length; i++) {
					values[i] = other.values[i - length];
				}
			}
		}
	}



	@Override
	public char getSVGCommandLetter() {
		return command;
	}
}
